package com.xxxcompany.shop.service.impl;

import java.sql.SQLException;

import com.xxxcompany.shop.dao.IUserDAO;
import com.xxxcompany.shop.dao.impl.UserDAOImpl;
import com.xxxcompany.shop.entity.User;
import com.xxxcompany.shop.service.IUserService;

public class UserServiceImpl implements IUserService{

	// 
	IUserDAO userDAO = new UserDAOImpl();
	
	@Override
	public boolean login(String username, String password) 
	{
		User user = null;
		try {
			user = userDAO.find(username, password);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return user!=null;
	}

	@Override
	public int insert(String username, String password) {
		// TODO Auto-generated method stub
		int result = 0;
		User u = new User();
		u.setPassword(password);
		u.setUsername(username);
		try {
			result = userDAO.insert(u);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

}